import java.util.ArrayList;
//定义Javabean类:Phone,属性:品牌,价格
//main方法中定义一个集合,存入三个手机对象
//分别为:小米,1000.苹果,8000.锤子,2999.
//定义一个方法,将价格低于3000的手机信息返回
public class A41{
    public static void main(String[] args){
        ArrayList<Phone> list = new ArrayList<>();
        Phone p1 = new Phone("小米",1000);
        Phone p2 = new Phone("苹果",8000);
        Phone p3 = new Phone("锤子",2999);
        list.add(p1);
        list.add(p2);
        list.add(p3);
        ArrayList<Phone> list1 = contains(list);
        for (int i = 0; i < list1.size(); i++) {
            System.out.println(list1.get(i).getBrand()+","+list1.get(i).getPrice());
        }
    }
    public static ArrayList<Phone> contains(ArrayList<Phone> list){
        ArrayList<Phone> list1 = new ArrayList<>();
        for(int i = 0;i < list.size();i++){
            if(list.get(i).getPrice() < 3000){
                list1.add(list.get(i));
            }
        }
        return list1;
    }
    public static class Phone{
        private String brand;
        private int price;
        public Phone() {
        }
        public Phone(String brand, int price) {
            this.brand = brand;
            this.price = price;
        }
        public String getBrand() {
            return brand;
        }
        public void setBrand(String brand) {
            this.brand = brand;
        }
        public int getPrice() {
            return price;
        }
        public void setPrice(int price) {
            this.price = price;
        }
    }
}

